!*****triplet lattice for ffag
option,echo,rbarc=false;
   L1 : drift, L= 2.832695;
   L2 : drift, L= 0.45698;
   L3 : drift, L= 0.08902;
   L4 : drift, L= 0.2155;
   L5 : drift, L= 0.219;
   L6 : drift, L= 0.107078;
   L7 : drift, L= 0.105716;
   L8 : drift, L= 0.135904;
   L9 : drift, L= 0.2156993;
   L10: drift, L= 0.089084;
   L11: drift, L= 0.235416;
   L12: drift, L= 0.1245;
   L13: drift, L= 0.511844;
   L14: drift, L= 0.1788541;
   L15: drift, L= 0.1788483;
   L16: drift, L= 0.511849;
   L17: drift, L= 0.1245;
   L18: drift, L= 0.235405;
   L19: drift, L= 0.089095;
   L20: drift, L= 0.2157007;
   L21: drift, L= 0.177716;
   L22: drift, L= 0.170981;
   L23: drift, L= 0.218997;
   L24: drift, L= 0.215503;
   L25: drift, L= 0.0890187;
   L26: drift, L= 0.45698;
   L27: drift, L= 2.832696;
   L27a: drift, L= 0.8596;
   L27b: drift, L= 0.1524;
   L27c: drift, L= 0.04445;
   L27d: drift, L= 1.776246;
   DS  : drift, L=0.1015;
   QF1   : QUADRUPOLE, L=0.344, K1= 2.2474+6.447435260914397E-03;  !  
   QF2   : QUADRUPOLE, L=0.344, K1= 2.2474; ! 
   QD1   : QUADRUPOLE, L=0.187, K1= -2.3368-2.593018157427161E-02; 
   QD2   : QUADRUPOLE, L=0.187, K1= -2.3368;    
   QFA1  : QUADRUPOLE, L=0.448, K1= 2.8856;    
   QFA2  : QUADRUPOLE, L=0.448, K1= 2.8856;  
!ksf=0.0;ksd=0.0;
ksf=(-41.67478927130080+0.3392376315938252)*2.0;ksd= (56.36083889436033-0.1043679358857811)*2.d0;
   sf  : sextupole, L=2.0*0.1015, K2= ksf;
   sd  : sextupole, L=2.0*0.1015, K2= ksd;
VC5: marker;
ALPHA=0.17453292519943295769236907684886;
 
LBEND=0.86621;
 
rcav=1.0;
 BEND : RBEND,L= LBEND, ANGLE=ALPHA,k1=-0.778741,truerbend=true,ptcrbend=true;   
 BEND1 : RBEND,L= LBEND, ANGLE=ALPHA,k1=-0.778741,truerbend=true,ptcrbend=true;   
CAV: RFCAVITY,L=0.0000,VOLT=-1.0*rcav,LAG=0.0,FREQ=500.0,no_cavity_totalpath;

!sfline: line=(sf);
!sdline: line=(sd);
sfline: line=(sf);
sdline: line=(sd);
SUP1 : LINE=  (    L1,L2,L3,QF1,VC5,L4,L5,QD1,L6,L7,L8,VC5,BEND,VC5,L9,sfline,L10,&
           L11,QFA1,L12,sdline,L13, &
           L14,BEND,L15,L16,sdline,L17, &
           QFA2,L18,L19,sfline,L20,BEND,L21,&
           L22,QD2,L23,L24,QF2,L25, &
           L26,VC5,L27);
SUPB : LINE=  (    L1,L2,L3,QF1,VC5,L4,L5,QD1,L6,L7,L8,VC5,BEND,VC5,L9,sfline,L10,&
           L11,QFA1,L12,sdline,L13, &
           L14,BEND,L15,L16,sdline,L17, &
           QFA2,L18,L19,sfline,L20,BEND1,L21,&
           L22,QD2,L23,L24,QF2,L25, &
           L26,VC5,L27,cav);


ALS : line = (11*sup1,supb,cav);
 

BEAM, particle=positron, energy=1.5;  


use, period=als;

ptc_open_gino, command=opengino;
ptc_create_universe;


use, period=ALS;
ptc_create_layout,model=1,method=6,nst=3;  !,exact;


ptc_script, file="flat.txt";

ptc_open_gino, command=mini;
ptc_open_gino, command=closegino;
stop;

